﻿@{
    ViewBag.Title = "Statistics";
}

<h2>Statistics</h2>
@Html.Partial("Styles")
@Html.Partial("Script")

<br />

<b>Worst selling album(s)</b>

@{
    int count = 0;
    int COLUMN_SIZE = 2;
}

<div align="center" style="overflow:auto">
    <table>
      <col width="350px">
      <col width="200px">

        <tr>
        @for (int i = 0; i < ViewBag.WorstSellingAlbum.Count; i++)
        {
            <td>
                <img src="../Content/Image/emeil.jpg" style="height: 200px" onclick="ViewAlbum(@ViewBag.WorstSellingAlbum[i].ID)">
                <br /><b>@ViewBag.WorstSellingAlbum[i].Title</b>
                <br />$@ViewBag.WorstSellingAlbum[i].Price
                <br />@ViewBag.wsaNum
                <br />
                <br />&nbsp
            </td>
                if (++count % COLUMN_SIZE == 0)
                {                     
                @:</tr> 
                @:<tr> 
                }

        }
        </tr>

    </table>
</div>
<br />
<br />


<hr width="900" />

<b>Worst selling song(s)</b>
<div align="center" style="overflow:auto">
    <table style="height:200px">
      <col width="500px">
      <col width="500px">
      <col width="100px">
      <col width="100px">
      <col width="100px">
      <col width="100px">
    <tr>
      <td><b>Title</b></td> 
      <td><b>Artist</b></td>
      <td><b>Duration</b></td>
      <td><b>Price</b></td>
    </tr>


     @for (int i = 0; i < ViewBag.worseSellingSong.Count; i++)
     {
         string artist = "";     
         <tr>
            <td>@ViewBag.worseSellingSong[i].Title</td>
            <td>
                @for (int k = 0; k < ViewBag.worseSellingSong[i].Artists.Count; k++)
                {
                    if (k == 0)
                    {
                        artist = ViewBag.worseSellingSong[i].Artists[k].Name;
                    }
                    else
                    {
                        artist = artist + " & " + ViewBag.worseSellingSong[i].Artists[k].Name;
                    }
                }
                @Html.Raw(artist)
            </td> 
            <td>@ViewBag.worseSellingSong[i].Duration</td>
            <td>$@ViewBag.worseSellingSong[i].Price</td>
            <td>@ViewBag.wssNum</td>
            <td><input type="button" onclick="ViewSong(@ViewBag.worseSellingSong[i].ID)" value="Details" /></td>
            <td>&nbsp&nbsp</td>
        </tr>
     }
    
    </table>
</div>
<br />
<br />


<hr width="900" />
<b>Deleted albums</b>
<div align="center" style="overflow:auto">
    <table>
      <col width="350px">
      <col width="200px">

        <tr>
        @for (int i = 0; i < ViewBag.deletedAlbums.Count; i++)
        {
            <td>
                <img src="../Content/Image/emeil.jpg" style="height: 200px">
                <br /><b>@ViewBag.deletedAlbums[i].Title</b>
                <br />$@ViewBag.deletedAlbums[i].Price
                <br />
                <br />&nbsp
            </td>
                if (++count % COLUMN_SIZE == 0)
                {                     
                @:</tr> 
                @:<tr> 
                }

        }
        </tr>

    </table>
</div>
<br />
<br />
<hr width ="900" />

<b>Deleted songs</b>
<div align="center" style="overflow:auto">
    <table style="height:200px">
      <col width="500px">
      <col width="500px">
      <col width="100px">
      <col width="100px">
      <col width="100px">
      <col width="100px">
    <tr>
      <td><b>Title</b></td> 
      <td><b>Artist</b></td>
      <td><b>Duration</b></td>
      <td><b>Price</b></td>
    </tr>


     @for (int i = 0; i < ViewBag.deletedSongs.Count; i++)
     {
         string artist = "";     
         <tr>
            <td>@ViewBag.deletedSongs[i].Title</td>
            <td>
                @for (int k = 0; k < ViewBag.deletedSongs[i].Artists.Count; k++)
                {
                    if (k == 0)
                    {
                        artist = ViewBag.deletedSongs[i].Artists[k].Name;
                    }
                    else
                    {
                        artist = artist + " & " + ViewBag.deletedSongs[i].Artists[k].Name;
                    }
                }
                @Html.Raw(artist)
            </td> 
            <td>@ViewBag.deletedSongs[i].Duration</td>
            <td>$@ViewBag.deletedSongs[i].Price</td>
            <td>&nbsp&nbsp</td>
        </tr>
     }
    
    </table>
</div>
<br />
<br />


<hr width="900" />
<b>Top 5 Artists</b>
<div align="center" style="overflow:auto">
    <table style="height:200px">
      <col width="500px">
      <col width="500px">
      <col width="100px">
      <col width="100px">
      <col width="100px">
      <col width="100px">
    <tr>
      <td><b>ID</b></td> 
      <td><b>Name</b></td>
      <td><b>Sales by song</b></td>
    </tr>


     @for (int i = 0; i < ViewBag.top5Artists.Count; i++)
     {
         <tr>
            <td>@ViewBag.top5Artists[i].ID</td> 
            <td>@ViewBag.top5Artists[i].Name</td>
            <td>@ViewBag.t5ANum[i]</td>
            <td>&nbsp&nbsp</td>
        </tr>
     }
    
    </table>
</div>
<br />
<br />


<hr width ="900" />
<b>Total spent by customer</b>
<div align="center" style="overflow:auto">
    <table style="height:200px">
      <col width="500px">
      <col width="500px">
      <col width="100px">
      <col width="100px">
      <col width="100px">
      <col width="100px">
    <tr>
      <td><b>Customer</b></td> 
      <td><b>Amount</b></td>
    </tr>


     @for (int i = 0; i < ViewBag.totalSpentCustomer.Count; i++)
     {
         <tr>
            <td>@ViewBag.totalSpentCustomer[i].customer</td> 
            <td>@ViewBag.totalSpentCustomer[i].spent</td>
            <td>&nbsp&nbsp</td>
        </tr>
     }
    
    </table>
</div>
<br />
<br />